




*------------------------------------------------------------------------------
*  Dynamics in individual-level attitudes on federal and provincial level
*------------------------------------------------------------------------------

putexcel set "tables\dynamic_lazarsfeld.xlsx", sheet(vote_party) replace

putexcel A2 = "CDU"
putexcel A3 = "SPD"
putexcel A4 = "FDP"
putexcel A5 = "Grüne"
putexcel A6 = "Linke"
putexcel A7 = "AfD"

putexcel B1 = "Loyal"
putexcel C1 = "Parteiwechsel"
putexcel D1 = "Kristallisation"
putexcel E1 = "Schwankend"
putexcel F1 = "N"


//Formatting
putexcel A1:A7, right border(right double) overwritefmt
putexcel B1:F1,  bold  overwritefmt
*putexcel B1:E1, hcenter bold border(bottom) overwritefmt
*putexcel A1:A7, border(right F) 

//Candidates: Export distribution to Excel
local zeile = 1
foreach party of numlist 1 	4 5 6 7 322  {
	local zeile = `zeile' + 1
		fre	laztype2017	if wabshelp9 == `party'
		putexcel B`zeile' = matrix(r(valid)'/r(N_valid)), nformat(percent)
		fre	laztype2017	if wabshelp9 == `party'
		putexcel F`zeile' = `r(N_valid)'
}

*Gesamt
fre laztype2017 if !missing(wabsfull9)
